package com.service.impl;

import com.mapper.CourseMapper;
import com.pojo.Course;
import com.service.CourseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/3/23.
 */
@Service
public class CourseServiceImpl implements CourseService {
    @Resource
    private CourseMapper courseMapper;

    @Override
    public boolean addCourse(Course course) {
        return courseMapper.insert(course) > 0 ? true : false;
    }

    @Override
    public boolean delCourseById(Integer courseId) {
        return courseMapper.deleteByPrimaryKey(courseId) > 0 ? true : false;
    }

    @Override
    public boolean updateCourse(Course course) {
        return courseMapper.updateByPrimaryKeySelective(course) > 0 ? true : false;
    }

    @Override
    public List<Course> findAllCourse() {
        return courseMapper.selectAll();
    }

    @Override
    public Course findCourseById(Integer courseId) {
        return courseMapper.selectByPrimaryKey(courseId);
    }
}
